package com.chinasofti.project.web;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.chinasofti.project.dal.model.custom.BzProduct;
import com.chinasofti.project.service.product.ProductService;
import com.chinasofti.project.web.common.ControllerBase;

@Controller
public class HomeController extends ControllerBase {
	@Autowired
	private ProductService productService;

	@RequestMapping("home")
	public String loadMainPage(ModelMap mm, HttpSession httpSession) {
		List<List<BzProduct>> bookList = new ArrayList<>();
		// 第一块 有6张图片
		List<BzProduct> l1 = productService.theFirstImg("玄幻奇幻");
		bookList.add(l1);

		// 后5块 每块有8张图片
		String[] ss = { "武侠仙侠", "科幻灵异", "侦探", "心理", "历史" };
		for (String string : ss) {
			bookList.add(productService.otherImg(string));
		}
		System.out.println("============================>>>>>" + httpSession.getAttribute("user"));
		mm.put("user", httpSession.getAttribute("user"));
		mm.put("bookList", bookList);
		return "home";
	}
}
